﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace modbusslave
{
    class InputData
    {

        //  Pressure (bar)	  Temperature (C)	 DP (bar)	  Velocity (m/sec)	Quality factor	Water Cut	Scaled Density

        public float Pressure { set; get; }
        public float Temperature { set; get; }
        public float DP { set; get; }
        public float Velocity { set; get; }
        public float Quality_factor { set; get; }
        public float Water_Cut { set; get; }
        public ushort Scaled_Density { set; get; }
    }

    class InputDataList
    {
        public List<InputData> storage;
        
        public InputDataList(string filename)
        {
            storage = new List<InputData>();
            using (StreamReader inputHandle = new StreamReader(File.Open(filename,FileMode.Open,FileAccess.Read,FileShare.ReadWrite))){
                
                string temp;
                // first line is header so lets skip it

                //   order Pressure (bar),  Temperature (C),  Velocity (m/sec),Quality factor, DP (bar),Water Cut,Scaled Density
                inputHandle.ReadLine();

                while((temp = inputHandle.ReadLine())!=null){
                    string [] items = temp.Split(',');
                    InputData data = new InputData();
                    data.Pressure = float.Parse(items[0]);
                    data.Temperature = float.Parse(items[1]);
                    data.Velocity = float.Parse(items[2]);
                    data.Quality_factor = float.Parse(items[3]);
                    data.DP = float.Parse(items[4]);
                    data.Water_Cut = float.Parse(items[5]);
                    data.Scaled_Density = ushort.Parse(items[6]);

                    storage.Add(data);

                    
                }
            }
        }
    }
}
